﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Li.Contracts;
using Li.Service.IService;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using CommonTool;
using Microsoft.AspNetCore.Authorization;
using Li.Contracts.OutputDto;
using Li.Web.Providers;

namespace Li.Web.Controllers
{
    
    public class AccessController : Controller
    {
        ICodeUserService _codeUserService;
        public AccessController(ICodeUserService codeUserService)
        {
            _codeUserService = codeUserService;
        }
        public IActionResult Index()
        {
            return View();
        }
        [AllowAnonymous]
        public IActionResult Login(LoginInputDto input)
        {
            return View();
        }
        [AllowAnonymous]
        public IActionResult UserLogin(LoginInputDto input)
        {
            var result = _codeUserService.CheckLogin(input);
            if(result!=null)
            {
                HttpContext.Session.SetString("CurrentLoginUser", result.ToJson());
            }
            return Json(new ResultReponse(true,"",null));
        }
    }
}